<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="address" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{addressHome.managed ? 'Edit' : 'Add'} Address</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{addressHome.managed}"
                          value="#{addressHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="addressLine1Field" template="layout/edit.xhtml">
                <ui:define name="label">Address line1</ui:define>
                <h:inputText id="addressLine1"
                           size="50"
                      maxlength="50"
                          value="#{addressHome.instance.addressLine1}">
                    <a:support event="onblur" reRender="addressLine1Field" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="addressLine2Field" template="layout/edit.xhtml">
                <ui:define name="label">Address line2</ui:define>
                <h:inputText id="addressLine2"
                           size="50"
                      maxlength="50"
                          value="#{addressHome.instance.addressLine2}">
                    <a:support event="onblur" reRender="addressLine2Field" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="cityField" template="layout/edit.xhtml">
                <ui:define name="label">City</ui:define>
                <h:inputText id="city"
                           size="50"
                      maxlength="50"
                          value="#{addressHome.instance.city}">
                    <a:support event="onblur" reRender="cityField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="stateField" template="layout/edit.xhtml">
                <ui:define name="label">State</ui:define>
                <h:inputText id="state"
                           size="50"
                      maxlength="50"
                          value="#{addressHome.instance.state}">
                    <a:support event="onblur" reRender="stateField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="countryField" template="layout/edit.xhtml">
                <ui:define name="label">Country</ui:define>
                <h:inputText id="country"
                           size="50"
                      maxlength="50"
                          value="#{addressHome.instance.country}">
                    <a:support event="onblur" reRender="countryField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="pinField" template="layout/edit.xhtml">
                <ui:define name="label">Pin</ui:define>
                <h:inputText id="pin"
                          value="#{addressHome.instance.pin}">
                    <a:support event="onblur" reRender="pinField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>





            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{addressHome.persist}"
                       disabled="#{!addressHome.wired}"
                       rendered="#{!addressHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{addressHome.update}"
                       rendered="#{addressHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{addressHome.remove}"
                      immediate="true"
                       rendered="#{addressHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Address.xhtml"
                rendered="#{addressHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty addressFrom ? 'AddressList' : addressFrom}.xhtml"
                rendered="#{!addressHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Teachers for present address id">
        <h:form styleClass="association" id="teachersForPresentAddressIdChildren">

            <h:outputText value="There are no teachersForPresentAddressId associated with this address."
                       rendered="#{empty addressHome.teachersForPresentAddressId}"/>

            <rich:dataTable value="#{addressHome.teachersForPresentAddressId}"
                           var="_teacher"
                      rendered="#{not empty addressHome.teachersForPresentAddressId}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="teachersForPresentAddressIdTable">
                <rich:column sortBy="#{_teacher.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_teacher.id}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.firstName}">
                    <f:facet name="header">First name</f:facet>
                    <h:outputText value="#{_teacher.firstName}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.lastName}">
                    <f:facet name="header">Last name</f:facet>
                    <h:outputText value="#{_teacher.lastName}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.passportPhotoUrl}">
                    <f:facet name="header">Passport photo url</f:facet>
                    <h:outputText value="#{_teacher.passportPhotoUrl}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.subject}">
                    <f:facet name="header">Subject</f:facet>
                    <h:outputText value="#{_teacher.subject}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.dateOfBirth}">
                    <f:facet name="header">Date of birth</f:facet>
                    <h:outputText value="#{_teacher.dateOfBirth}">
                        <s:convertDateTime type="date" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_teacher.qualification}">
                    <f:facet name="header">Qualification</f:facet>
                    <h:outputText value="#{_teacher.qualification}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.mobileNumber}">
                    <f:facet name="header">Mobile number</f:facet>
                    <h:outputText value="#{_teacher.mobileNumber}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.contactNumberInCaseOfEmergency}">
                    <f:facet name="header">Contact number in case of emergency</f:facet>
                    <h:outputText value="#{_teacher.contactNumberInCaseOfEmergency}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.comments}">
                    <f:facet name="header">Comments</f:facet>
                    <h:outputText value="#{_teacher.comments}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{addressHome.managed}" id="teachersForPresentAddressId">
        <div class="actionButtons">
            <s:button id="addteacher"
                   value="Add teacher"
                    view="/TeacherEdit.xhtml"
             propagation="none">
                 <f:param name="addressId"
                         value="#{addressHome.instance.id}"/>
                 <f:param name="teacherFrom" value="Address"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Student previous acad detailses">
        <h:form styleClass="association" id="studentPreviousAcadDetailsesChildren">

            <h:outputText value="There are no studentPreviousAcadDetailses associated with this address."
                       rendered="#{empty addressHome.studentPreviousAcadDetailses}"/>

            <rich:dataTable value="#{addressHome.studentPreviousAcadDetailses}"
                           var="_studentPreviousAcadDetails"
                      rendered="#{not empty addressHome.studentPreviousAcadDetailses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentPreviousAcadDetailsesTable">
                <rich:column sortBy="#{_studentPreviousAcadDetails.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.courseName}">
                    <f:facet name="header">Course name</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.courseName}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.instName}">
                    <f:facet name="header">Inst name</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.instName}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.phone}">
                    <f:facet name="header">Phone</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.phone}"/>
                </rich:column>
                <rich:column sortBy="#{_studentPreviousAcadDetails.decription}">
                    <f:facet name="header">Decription</f:facet>
                    <h:outputText value="#{_studentPreviousAcadDetails.decription}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{addressHome.managed}" id="studentPreviousAcadDetailses">
        <div class="actionButtons">
            <s:button id="addstudentPreviousAcadDetails"
                   value="Add studentPreviousAcadDetails"
                    view="/StudentPreviousAcadDetailsEdit.xhtml"
             propagation="none">
                 <f:param name="addressId"
                         value="#{addressHome.instance.id}"/>
                 <f:param name="studentPreviousAcadDetailsFrom" value="Address"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Teachers for permanent address id">
        <h:form styleClass="association" id="teachersForPermanentAddressIdChildren">

            <h:outputText value="There are no teachersForPermanentAddressId associated with this address."
                       rendered="#{empty addressHome.teachersForPermanentAddressId}"/>

            <rich:dataTable value="#{addressHome.teachersForPermanentAddressId}"
                           var="_teacher"
                      rendered="#{not empty addressHome.teachersForPermanentAddressId}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="teachersForPermanentAddressIdTable">
                <rich:column sortBy="#{_teacher.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_teacher.id}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.firstName}">
                    <f:facet name="header">First name</f:facet>
                    <h:outputText value="#{_teacher.firstName}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.lastName}">
                    <f:facet name="header">Last name</f:facet>
                    <h:outputText value="#{_teacher.lastName}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.passportPhotoUrl}">
                    <f:facet name="header">Passport photo url</f:facet>
                    <h:outputText value="#{_teacher.passportPhotoUrl}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.subject}">
                    <f:facet name="header">Subject</f:facet>
                    <h:outputText value="#{_teacher.subject}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.dateOfBirth}">
                    <f:facet name="header">Date of birth</f:facet>
                    <h:outputText value="#{_teacher.dateOfBirth}">
                        <s:convertDateTime type="date" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_teacher.qualification}">
                    <f:facet name="header">Qualification</f:facet>
                    <h:outputText value="#{_teacher.qualification}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.mobileNumber}">
                    <f:facet name="header">Mobile number</f:facet>
                    <h:outputText value="#{_teacher.mobileNumber}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.contactNumberInCaseOfEmergency}">
                    <f:facet name="header">Contact number in case of emergency</f:facet>
                    <h:outputText value="#{_teacher.contactNumberInCaseOfEmergency}"/>
                </rich:column>
                <rich:column sortBy="#{_teacher.comments}">
                    <f:facet name="header">Comments</f:facet>
                    <h:outputText value="#{_teacher.comments}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{addressHome.managed}" id="teachersForPermanentAddressId">
        <div class="actionButtons">
            <s:button id="addteacher"
                   value="Add teacher"
                    view="/TeacherEdit.xhtml"
             propagation="none">
                 <f:param name="addressId"
                         value="#{addressHome.instance.id}"/>
                 <f:param name="teacherFrom" value="Address"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Parents">
        <h:form styleClass="association" id="parentsChildren">

            <h:outputText value="There are no parents associated with this address."
                       rendered="#{empty addressHome.parents}"/>

            <rich:dataTable value="#{addressHome.parents}"
                           var="_parent"
                      rendered="#{not empty addressHome.parents}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="parentsTable">
                <rich:column sortBy="#{_parent.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_parent.id}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.firstName}">
                    <f:facet name="header">First name</f:facet>
                    <h:outputText value="#{_parent.firstName}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.lastName}">
                    <f:facet name="header">Last name</f:facet>
                    <h:outputText value="#{_parent.lastName}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.mobileNumber}">
                    <f:facet name="header">Mobile number</f:facet>
                    <h:outputText value="#{_parent.mobileNumber}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.officePhone}">
                    <f:facet name="header">Office phone</f:facet>
                    <h:outputText value="#{_parent.officePhone}"/>
                </rich:column>
                <rich:column sortBy="#{_parent.email}">
                    <f:facet name="header">Email</f:facet>
                    <h:outputText value="#{_parent.email}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{addressHome.managed}" id="parents">
        <div class="actionButtons">
            <s:button id="addparent"
                   value="Add parent"
                    view="/ParentEdit.xhtml"
             propagation="none">
                 <f:param name="addressId"
                         value="#{addressHome.instance.id}"/>
                 <f:param name="parentFrom" value="Address"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
